from PyQt5.QtWidgets import *


class LoginDialog(QDialog):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("登录")
        self.userEdit = QLineEdit(self)
        self.passwordEdit = QLineEdit(self)
        self.btnYes = QPushButton("确定")
        self.btnNo = QPushButton("取消")
        fl = QFormLayout()
        fl.addRow("用户名：", self.userEdit)
        fl.addRow("密码：", self.passwordEdit)
        hl = QHBoxLayout()
        hl.addStretch()
        hl.addWidget(self.btnNo)
        hl.addWidget(self.btnYes)
        vl = QVBoxLayout()
        vl.addLayout(fl)
        vl.addLayout(hl)

        self.setLayout(vl)
        self.btnYes.clicked.connect(self.accept)
        self.btnNo.clicked.connect(self.reject)

        self.userEdit.setText("admin")
        self.passwordEdit.setText("123456")

    def username(self):
        return self.userEdit.text().strip()

    def password(self):
        return self.passwordEdit.text().strip()
